// JavaScript Document


 function check()
 {
  if(form1.title.value=="")
  {
   alert('项目名称不能为空！！');
      }
  else if(form1.time.value=="")
  {
	  alert('项目申请时间不能为！空！');
	  }
  else if(form1.address.value=="")
  {
	  alert('项目申请地址不能为空！！');
	  }
  else if(form1.money.value=="")
  {
	  alert('项目申请资金不能为空！！	');
	  }
  else if(form1.file.value=="")
  {
	  alert('项目申请文件号不能为空！！	');
	  }
 else  if(form1.career.value=="")
  {
	  alert('项目申请工作单位不能为空！！	');
	  }
  else if(form1.pers1.value=="")
  {
	  alert('项目申请单位法人不能为空！！	');
	  }
  else if(form1.pers2.value=="")
  {
	  alert('项目申请技术负责人不能为空！！	');
	  }
  else if(form1.intro1.value=="")
  {
	  alert('项目申请县级推荐号不能为空！！	');
	  }
  else if(form1.intro2.value=="")
  {
	  alert('项目申请市级推荐号不能为空！！	');
	  }
  else if(form1.app1.value=="")
  {
	  alert('项目申请县级审核号不能为空！！	');
  }
  else if(form1.app2.value=="")
  {
	  alert('项目申请市级审核号不能为空！！	');
	  }
  else if(form1.app3.value=="")
  {
	  alert('项目申请不能省级审核号为空！！	');
	  }
  else if(form1.area.value=="")
  {
	  alert('项目申请内容介绍不能为空！！');
	  }
 }
 /* date select */
 function HS_DateAdd(interval,number,date){
	number = parseInt(number);
	if (typeof(date)=="string"){var date = new Date(date.split("-")[0],date.split("-")[1],date.split("-")[2])}
	if (typeof(date)=="object"){var date = date}
	switch(interval){
	case "y":return new Date(date.getFullYear()+number,date.getMonth(),date.getDate()); break;
	case "m":return new Date(date.getFullYear(),date.getMonth()+number,checkDate(date.getFullYear(),date.getMonth()+number,date.getDate())); break;
	case "d":return new Date(date.getFullYear(),date.getMonth(),date.getDate()+number); break;
	case "w":return new Date(date.getFullYear(),date.getMonth(),7*number+date.getDate()); break;
	}
}
function checkDate(year,month,date){
	var enddate = ["31","28","31","30","31","30","31","31","30","31","30","31"];
	var returnDate = "";
	if (year%4==0){enddate[1]="29"}
	if (date>enddate[month]){returnDate = enddate[month]}else{returnDate = date}
	return returnDate;
}

function WeekDay(date){
	var theDate;
	if (typeof(date)=="string"){theDate = new Date(date.split("-")[0],date.split("-")[1],date.split("-")[2]);}
	if (typeof(date)=="object"){theDate = date}
	return theDate.getDay();
}
function HS_calender(){
	var lis = "";
	var style = "";
	style +="<style type='text/css'>";
	style +=".calender { width:170px; height:auto; font-size:12px; margin-right:14px; background:url(calenderbg.gif) no-repeat right center #fff; border:1px solid #397EAE; padding:1px}";
	style +=".calender ul {list-style-type:none; margin:0; padding:0;}";
	style +=".calender .day { background-color:#EDF5FF; height:20px;}";
	style +=".calender .day li,.calender .date li{ float:left; width:14%; height:20px; line-height:20px; text-align:center}";
	style +=".calender li a { text-decoration:none; font-family:Tahoma; font-size:11px; color:#333}";
	style +=".calender li a:hover { color:#f30; text-decoration:underline}";
	style +=".calender li a.hasArticle {font-weight:bold; color:#f60 !important}";
	style +=".lastMonthDate, .nextMonthDate {color:#bbb;font-size:11px}";
	style +=".selectThisYear a, .selectThisMonth a{text-decoration:none; margin:0 2px; color:#000; font-weight:bold}";
	style +=".calender .LastMonth, .calender .NextMonth{ text-decoration:none; color:#000; font-size:18px; font-weight:bold; line-height:16px;}";
	style +=".calender .LastMonth { float:left;}";
	style +=".calender .NextMonth { float:right;}";
	style +=".calenderBody {clear:both}";
	style +=".calenderTitle {text-align:center;height:20px; line-height:20px; clear:both}";
	style +=".today { background-color:#ffffaa;border:1px solid #f60; padding:2px}";
	style +=".today a { color:#f30; }";
	style +=".calenderBottom {clear:both; border-top:1px solid #ddd; padding: 3px 0; text-align:left}";
	style +=".calenderBottom a {text-decoration:none; margin:2px !important; font-weight:bold; color:#000}";
	style +=".calenderBottom a.closeCalender{float:right}";
	style +=".closeCalenderBox {float:right; border:1px solid #000; background:#fff; font-size:9px; width:11px; height:11px; line-height:11px; text-align:center;overflow:hidden; font-weight:normal !important}";
	style +="</style>";

	var now;
	if (typeof(arguments[0])=="string"){
		selectDate = arguments[0].split("-");
		var year = selectDate[0];
		var month = parseInt(selectDate[1])-1+"";
		var date = selectDate[2];
		now = new Date(year,month,date);
	}else if (typeof(arguments[0])=="object"){
		now = arguments[0];
	}
	var lastMonthEndDate = HS_DateAdd("d","-1",now.getFullYear()+"-"+now.getMonth()+"-01").getDate();
	var lastMonthDate = WeekDay(now.getFullYear()+"-"+now.getMonth()+"-01");
	var thisMonthLastDate = HS_DateAdd("d","-1",now.getFullYear()+"-"+(parseInt(now.getMonth())+1).toString()+"-01");
	var thisMonthEndDate = thisMonthLastDate.getDate();
	var thisMonthEndDay = thisMonthLastDate.getDay();
	var todayObj = new Date();
	today = todayObj.getFullYear()+"-"+todayObj.getMonth()+"-"+todayObj.getDate();
	
	for (i=0; i<lastMonthDate; i++){  // Last Month's Date
		lis = "<li class='lastMonthDate'>"+lastMonthEndDate+"</li>" + lis;
		lastMonthEndDate--;
	}
	for (i=1; i<=thisMonthEndDate; i++){ // Current Month's Date

		if(today == now.getFullYear()+"-"+now.getMonth()+"-"+i){
			var todayString = now.getFullYear()+"-"+(parseInt(now.getMonth())+1).toString()+"-"+i;
			lis += "<li><a href=javascript:void(0) class='today' onclick='_selectThisDay(this)' title='"+now.getFullYear()+"-"+(parseInt(now.getMonth())+1)+"-"+i+"'>"+i+"</a></li>";
		}else{
			lis += "<li><a href=javascript:void(0) onclick='_selectThisDay(this)' title='"+now.getFullYear()+"-"+(parseInt(now.getMonth())+1)+"-"+i+"'>"+i+"</a></li>";
		}
		
	}
	var j=1;
	for (i=thisMonthEndDay; i<6; i++){  // Next Month's Date
		lis += "<li class='nextMonthDate'>"+j+"</li>";
		j++;
	}
	lis += style;

	var CalenderTitle = "<a href='javascript:void(0)' class='NextMonth' onclick=HS_calender(HS_DateAdd('m',1,'"+now.getFullYear()+"-"+now.getMonth()+"-"+now.getDate()+"'),this) title='Next Month'>&raquo;</a>";
	CalenderTitle += "<a href='javascript:void(0)' class='LastMonth' onclick=HS_calender(HS_DateAdd('m',-1,'"+now.getFullYear()+"-"+now.getMonth()+"-"+now.getDate()+"'),this) title='Previous Month'>&laquo;</a>";
	CalenderTitle += "<span class='selectThisYear'><a href='javascript:void(0)' onclick='CalenderselectYear(this)' title='Click here to select other year' >"+now.getFullYear()+"</a></span>年<span class='selectThisMonth'><a href='javascript:void(0)' onclick='CalenderselectMonth(this)' title='Click here to select other month'>"+(parseInt(now.getMonth())+1).toString()+"</a></span>月"; 

	if (arguments.length>1){
		arguments[1].parentNode.parentNode.getElementsByTagName("ul")[1].innerHTML = lis;
		arguments[1].parentNode.innerHTML = CalenderTitle;

	}else{
		var CalenderBox = style+"<div class='calender'><div class='calenderTitle'>"+CalenderTitle+"</div><div class='calenderBody'><ul class='day'><li>日</li><li>一</li><li>二</li><li>三</li><li>四</li><li>五</li><li>六</li></ul><ul class='date' id='thisMonthDate'>"+lis+"</ul></div><div class='calenderBottom'><a href='javascript:void(0)' class='closeCalender' onclick='closeCalender(this)'>×</a><span><span><a href=javascript:void(0) onclick='_selectThisDay(this)' title='"+todayString+"'>Today</a></span></span></div></div>";
		return CalenderBox;
	}
}
function _selectThisDay(d){
	var boxObj = d.parentNode.parentNode.parentNode.parentNode.parentNode;
		boxObj.targetObj.value = d.title;
		boxObj.parentNode.removeChild(boxObj);
}
function closeCalender(d){
	var boxObj = d.parentNode.parentNode.parentNode;
		boxObj.parentNode.removeChild(boxObj);
}

function CalenderselectYear(obj){
		var opt = "";
		var thisYear = obj.innerHTML;
		for (i=1970; i<=2020; i++){
			if (i==thisYear){
				opt += "<option value="+i+" selected>"+i+"</option>";
			}else{
				opt += "<option value="+i+">"+i+"</option>";
			}
		}
		opt = "<select onblur='selectThisYear(this)' onchange='selectThisYear(this)' style='font-size:11px'>"+opt+"</select>";
		obj.parentNode.innerHTML = opt;
}

function selectThisYear(obj){
	HS_calender(obj.value+"-"+obj.parentNode.parentNode.getElementsByTagName("span")[1].getElementsByTagName("a")[0].innerHTML+"-1",obj.parentNode);
}

function CalenderselectMonth(obj){
		var opt = "";
		var thisMonth = obj.innerHTML;
		for (i=1; i<=12; i++){
			if (i==thisMonth){
				opt += "<option value="+i+" selected>"+i+"</option>";
			}else{
				opt += "<option value="+i+">"+i+"</option>";
			}
		}
		opt = "<select onblur='selectThisMonth(this)' onchange='selectThisMonth(this)' style='font-size:11px'>"+opt+"</select>";
		obj.parentNode.innerHTML = opt;
}
function selectThisMonth(obj){
	HS_calender(obj.parentNode.parentNode.getElementsByTagName("span")[0].getElementsByTagName("a")[0].innerHTML+"-"+obj.value+"-1",obj.parentNode);
}
function HS_setDate(inputObj){
	var calenderObj = document.createElement("span");
	calenderObj.innerHTML = HS_calender(new Date());
	calenderObj.style.position = "absolute";
	calenderObj.targetObj = inputObj;
	inputObj.parentNode.insertBefore(calenderObj,inputObj.nextSibling);
}

/* address */
//定义城市数组
var coun=new Array(
					   new Array("成华区","武侯区","青羊区","锦江区","金牛区","龙泉驿区","青白江区","新都区","双流县","郫县","温江区","大邑县","金堂县","蒲                                 江县","新津县","都江堰市","彭州市","崇州市","邛崃市", "其他"),
					   new Array("自流井区","贡井区","大安区","沿滩区和荣县","富顺县","其他"),
					   new Array("东区","西区","仁和区","米易县","盐边县","其他"), 
					   new Array("江阳区","纳溪区","龙马潭区","泸县","合江县","叙永县","古蔺县","其他"),
					   new Array("旌阳区","中江县","罗江县","广汉市","绵竹市","什邡市","其他"), 
					   new Array("涪城区","游仙区","江油市","三台县","安县","平武县","梓潼县","盐亭县","北川羌族自治县","其他"),
					   new Array("利州区","元坝区","朝天区","旺苍县","青川县","剑阁县","苍溪县","其他"), 
					   new Array("船山区","安居区","蓬溪县","大英县","射洪县","其他"), 
					   new Array("市中区","东兴区","资中县","隆昌县","威远县","其他"), 
					   new Array("市中区","五通桥","沙湾","金口河4个区，犍为县","井研县","夹江县","沐川县","峨边彝族自治县",
					               "马边彝族自治县","峨眉山市","其他"),
					   new Array("顺庆区","高坪区","嘉陵区","南部县","仪陇县","西充县","蓬安县","营山县","阆中市","其他"),
					   new Array("东坡区","仁寿县","彭山县","洪雅县","丹棱县","青神县","其他"),
					   new Array("翠屏区","宜宾县","南溪县","江安县","长宁县","高县","珙县","筠连县","兴文县","屏山县","其他"),
					   new Array("广安区","岳池县","武胜县","邻水县","华蓥市","其他"),
					   new Array("通川区","达县","宣汉县","开江县","大竹县","渠县","万源市","其他"),
					   new Array("雨城区","芦山县","名山县","天全县","荥经县","宝兴县","汉源县","石棉县","其他"),
					   new Array("巴州区","通江县","南江县","平昌县","其他"),
					   new Array("雁江区","安岳县","乐至县，简阳市","其他"),
					   new Array("汶川县","理县","茂县","松潘县","金川县","黑水县","马尔康县","壤塘县","阿坝县","若尔盖县","红原县",
					              "九寨沟县","小金县"," 其他"),
					   new Array("康定县","丹巴县","炉霍县","九龙县","甘孜县","雅江县","新龙县","道孚县","白玉县","理塘县","德格县",
					              "乡城县","石渠县","稻城县","色达县","巴塘县","泸定县","得荣县","其他"),
					   new Array("西昌市","木里县","盐源县","德昌县","会理县","会东县","宁南县","普格县","布拖县","金阳县","昭觉县",
					               "喜德县","冕宁县","越西县","甘洛县","美姑县","雷波县","其他")
					   
					);
function scity(pname,cname,sf,cs){
	/*
		自定义函数中pname代表传进来的省份下拉框的name值，
		cname代表传进来的城市下拉框的name值
		sf代表传进来的省份值
		cs代表传进来的城市值
	*/
	//定义省份数组
	var city=["成都市","自贡市","攀枝花市","泸州市","德阳市","绵阳市","广元市","遂宁市","内江市"," 乐山市","南充市",
				  "眉山市","宜宾市","广安市","达州市","雅安市","巴中市","资阳市","阿坝藏族羌族自治州","甘孜藏族自治州","凉山彝族自治州","其它"];
				/*
					省份下拉框
				*/	
					document.write('<select style=" width:150px; height:30px; font-size:14px;" id="city" onchange="select_city(this)" name="pro">');
							document.write('<option value="">--请选择城市--</option>');
						var a=0;
						for(var i=0;i<city.length;i++){					
							if(typeof(sf)!="undefined"){
								if(city[i]==sf){
									var sel="selected";
									a=i;
									}
								else
									var sel="";			
							}else{
								var sel="";
							}
							document.write('<option '+sel+' value="'+city[i]+'">'+city[i]+'</option>');
						}
					document.write('</select>');
					
				/*
					省份对应的城市下拉框
				*/	
					document.write('<select  style=" width:120px; height:30px;  font-size:14px;" id="coun" name="city">');
							document.write('<option value="">--请选择地区--</option>');			
					document.write('</select>');
				if(a>0){
					select_city(document.getElementById("city"),a,cs);
				}
					//
				}
function select_city(city_obj,a,cs){
	if(typeof(a)!="undefined"){
		var index=a;
	}else{
		var index=city_obj.selectedIndex-1;
	}
	var coun_obj=document.getElementById("coun");
		coun_obj.innerHTML="";
	if(index>=0){
		for(var i=0;i<coun[index].length;i++){
			if(typeof(cs)!=undefined){
				if(coun[index][i]==cs){
					var sel="selected";
				}else
					var sel="";
			}else{
				var sel="";
			}
			var option=document.createElement("option");
			var text=coun[index][i];
				option.value=text;
				option.selected=sel;
				option.innerHTML=text;
				coun_obj.appendChild(option);
			}
		}else{
			var option=document.createElement("option");
				option.innerHTML="--请选择地区--";
				coun_obj.appendChild(option);
	}
	
}				